//
//  SMTProtocols.h
//  smarthings
//
//  Created by Stefan Tsvyatkov on 10/20/14.
//  Copyright (c) 2014 Stefan Tsvyatkov. All rights reserved.
//

#ifndef smarthings_SMTProtocols_h
#define smarthings_SMTProtocols_h

@class SMTUser;
@class SMTThing;
@class SMTThingProperty;
@class SMTThingAction;
@class SMTRule;

#pragma mark - Interface protocols

@protocol SMTThingsManager <NSObject>

- (void)getThingsList;
- (void)deleteThing:(SMTThing *)thing;
- (void)addThing:(SMTThing *)thing;
- (void)editThing:(SMTThing *)thing;
- (void)getPropertyValue:(SMTThingProperty *)property;
- (void)executeAction:(SMTThingAction *)action;
+ (NSArray *)thingPropertyTypes;
+ (NSArray *)thingActionTypes;

@end

@protocol SMTRulesManager <NSObject>

- (void)getRulesList;
- (void)deleteRule:(SMTRule *)rule;
- (void)addRule:(SMTRule *)rule;
- (void)editRule:(SMTRule *)rule;

@end

@protocol SMTAccountsManager <NSObject>

- (void)authenticateWithUsername:(NSString *)username
                    andPassword:(NSString *)password;
- (void)forgotPasswordWithEmail:(NSString *)email;
- (void)registerUser:(SMTUser *)user;
- (void)editUser:(SMTUser *)user;
- (SMTUser *)currentUser;

@end

#pragma mark - Delegate Protocols

@protocol SMTThingsManagerDelegate <NSObject>

@optional
- (void)getThingsListFinishedWithFailure:(NSError *)error;
- (void)getThingsListFinishedWithSuccess:(NSArray *)things;
- (void)deleteThingFinishedWithFailure:(NSError *)error;
- (void)deleteThingFinishedWithSuccess:(NSString *)href;
- (void)addThingFinishedWithFailure:(NSError *)error;
- (void)addThingFinishedWithSuccess:(SMTThing *)thing;
- (void)editThingFinishedWithFailure:(NSError *)error;
- (void)editThingFinishedWithSuccess:(SMTThing *)thing;
- (void)getPropertyValueFinishedWithFailure:(NSError *)error;
- (void)getPropertyValueFinishedWithSuccess:(SMTThingProperty *)property forValue:(NSNumber *)value;
- (void)executeActionFinishedWithFailure:(NSError *)error;
- (void)executeActionFinishedWithSuccess:(SMTThingAction *)action;

@end

@protocol SMTRulesManagerDelegate <NSObject>

@optional
- (void)getRulesListFinishedWithFailure:(NSError *)error;
- (void)getRulesListFinishedWithSuccess:(NSArray *)rules;
- (void)deleteRuleFinishedWithFailure:(NSError *)error;
- (void)deleteRuleFinishedWithSuccess:(NSString *)href;
- (void)addRuleFinishedWithFailure:(NSError *)error;
- (void)addRuleFinishedWithSuccess:(SMTRule *)rule;
- (void)editRuleFinishedWithFailure:(NSError *)error;
- (void)editRuleFinishedWithSuccess:(SMTRule *)rule;

@end

@protocol SMTAccountsManagerDelegate <NSObject>

@optional
- (void)authenticationFinishedWithFailure:(NSError *)error;
- (void)authenticationFinishedWithSuccess:(SMTUser *)user;
- (void)forgotPasswordFinishedWIthFailure:(NSError *)error;
- (void)forgotPasswordFinishedWithSuccess;
- (void)registerUserFinishedWithFailure:(NSError *)error;
- (void)registerUserFinishedWithSuccess:(SMTUser *)user;
- (void)editUserFinishedWithFailure:(NSError *)error;
- (void)editUserFinishedWithSuccess:(SMTUser *)user;

@end


#endif
